
import java.util.Scanner;

/**
 * Created by forcht on 2018/4/25.
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int[] prices=new int[100000];
        int min=0,max=0,start,end,price;
        if(scanner.hasNext()){
            start=scanner.nextInt();
            end=scanner.nextInt();
            price=scanner.nextInt();
            min=start;
            max=end;
            for(int i=start;i<=end;i++){
                prices[i]=price;
            }
            while (scanner.hasNext()){
                start=scanner.nextInt();
                end=scanner.nextInt();
                price=scanner.nextInt();
                if(min>start)min=start;
                if(max<end) max=end;
                for(int i=start;i<=end;i++){
                    prices[i]=price;
                }
            }
        }
        System.out.print("["+min+", ");
        for(int i=min+1;i<=max;i++){
            if(prices[i]!=prices[i-1]){
                if (prices[i-1]!=0) System.out.print(i-1+", "+prices[i-1]+"]");
                if(i<max&&prices[i]!=0) System.out.print(",["+i+", ");
            }
        }
        System.out.print(max+", "+prices[max]+"]");
    }
}
